package com.power.project.model;

import com.power.common.domain.BaseModel;
import com.power.project.model.dto.UserTagDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 实体类
 */

@Entity
@ApiModel(value = "")
@Data
@Table(name = "Ww_usertag")
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
//@IdClass(Ww_usertag.Ww_usertagPK.class) 用于复合组件
public class Ww_usertag extends BaseModel implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(nullable = false)
    @ApiModelProperty(value = "")
    private Integer id;

    @ApiModelProperty(value = "标签id")
    private String tagid;

    @ApiModelProperty(value = "标签名")
    private String tagname;

    @ApiModelProperty(value = "用户id")
    private String wwuserid;

    @ApiModelProperty(value = "租户id")
    private String tenantid;


    public Map<String, Object> parseMap() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", this.getId());
        map.put("tagid", this.getTagid());
        map.put("tagname", this.getTagname());
        map.put("wwuserid", this.getWwuserid());
        map.put("tenantid", this.getTenantid());
        return map;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Serializable id) {
        this.id = (Integer) id;
    }

    public Serializable getPrimaryKey() {
        return id;
        // return new Ww_usertagPK(id, id2); 用于复合主键，请手动创建内部静态类
    }

    public void setPrimaryKey(Serializable key) {
        this.id = (Integer) key;

        //Ww_usertagPK pk = (Ww_usertagPK) key; 用于复合主键
        //this.id = pk.getId();
        //this.id2 = pk.getId2();
    }

    public Ww_usertag(Ww_tag tag, String userId) {
        this.tagid = tag.getTagid();
        this.tagname = tag.getName();
        this.wwuserid = userId;
        this.tenantid = tag.getTenantid();
    }

    public Ww_usertag(UserTagDTO tag, String userId, String tenantId) {
        this.tagid = tag.getTagId();
        this.tagname = tag.getName();
        this.wwuserid = userId;
        this.tenantid = tenantId;
    }
}